﻿$(function () {
    var win_wid = win.width(),
        body = document.body,
        show = $('.slideShow'),
        entries = $('.entries'),
        top     = entries.find('.top'),
        bot     = entries.find('.bottom'),
        entries_hei = 0,
        links = top.find('a'),
        link_wid = 60,
        len = links.length,
        mar = Math.floor((win_wid - (len * link_wid)) / (len * 2 + 2)), // 获取一个外边距值, 能让图标居中
        link_outWid = link_wid + (mar * 2);

    win.on('load', function () {
        console.log("加载")
        body.scrollTop = 0;
        links.css({ 'margin': mar, 'line-height': mar * 2 + 14 + 'px' });

        entries_hei = entries.height();

        // 版本1
        // show.height(win.height() - entries_hei - 72); // 72是header的固定高度
        // body.addEventListener('touchmove', function (e) { e.preventDefault() }, false);
        // 版本2
        // show.height( win.width() * parseInt(show.data('height')) / parseInt(show.data('width')));
        show.height(win.height() - 70 - link_outWid - (mar*3) -14 -3 -73); //73为红色选项栏高度

        setTimeout(function () {
            top.css({'height': link_outWid, 'padding': mar, 'padding-bottom': mar * 2 + 14 });
            bot.height(95);//  关注我们三大块
            setTimeout(function() {
                recu(links, 0, links.length, function (elem) {
                    elem.addClass('scaleOut');
                }, 100, function () {
                    setTimeout(function () {
                        links.removeClass('scaleNone scaleOut').find('.shadow').css({ '-webkit-transform': 'scale(1,1)', '-webkit-opacity': '0' });
                    }, 600);
                });
            }, 200);
        }, 300);
        setTimeout(function () {
            recu($('.news-list a'), 0, 2, function (elem) {
                elem.addClass('scaleOut');
            }, 250, function () {
                setTimeout(function () {
                    entries.css('background-color', '#ffffff');
                    $('.news-list a').removeClass('scaleNone scaleOut');
                }, 250);
            });
        }, 800);
        setTimeout(function() {
            $('#footer').height(80);
        }, 1000);

        function recu(coll, idx, len, func, timeout, callback) {
            func(coll.eq(idx));
            if (idx === len) {
                if (typeof callback === 'function') callback();
            } else {
                setTimeout(function () {
                    recu(coll, ++idx, len, func, timeout, callback);
                }, timeout);
            }
        }

        links.on('click', function () {
            $(this).addClass
        });

    }).on('resize', function () {
        console.log("大小改变")
        return;

        document.body.scrollTop = 0;
        show.css({ '-webkit-transition-duration': '100ms', 'height': win.height() - entries_hei - 72 });
    });
});